<%--
  Created by IntelliJ IDEA.
  User: lzc
  Date: 2018/4/12
  Time: 14:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>${wenku.docTitle}</title>
    <!-- Custom Theme files -->
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

    <link rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/layui.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/global.css">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

    <script>
        function download(){
            $.ajax({
                type: "POST",
                url: "${pageContext.request.contextPath}/file/download",
                data: {
                    docId:"${wenku.docId}",
                    fileType:"${wenku.docType}"
                },
                dataType: "text",
                success: function(data,textStatus){
                    alert("success")
                    window.location.href = "${pageContext.request.contextPath}/zipPath/${wenku.docId}.zip";
                },
                error:function(data){
                    alert("error")
                }
            });
        }
    </script>

</head>
<body  style="background-color: #F2F2F2;">
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <%--<form class="layui-form" action=""  style="padding: 20px; background-color: white;">
        <div class="layui-form-item">
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入关键字" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <button class="layui-btn" lay-submit="" lay-filter="demo1">搜索</button>
                </div>
            </div>
        </div>
    </form>--%>

    <div class="layui-container">
        <h1 class="site-h1"></h1>

        <div class="layui-row layui-col-space15">
            <div class="layui-col-md8">
                <%--<div class="grid-demo grid-demo-bg1">移动：12/12、桌面：8/12</div>--%>
                <div class="layui-card">
                    <div class="layui-card-body">
                        <div id="wenku_label">
                            <h1 class="site-h1">${wenku.docTitle}</h1>
                            <span id = "wenku_docLabel" class="layui-badge-rim" style="display: none">${wenku.docLabel}</span>
                            <span style="font-size: 14px;font-weight: 200;color: #393D49;">贡献者：${wenku.docAuthor}&nbsp;&nbsp;&nbsp;文件大小：<fmt:formatNumber type="number" value="${wenku.docSize/1024 }" pattern="0.00" maxFractionDigits="2"/> KB&nbsp;&nbsp;&nbsp;下载量：${wenku.downloads}</span>
                        </div>
                        <h1 class="site-h1" style="font-size: 20px;">${wenku.docDesc}</h1>
                        <div class="layui-btn-container">
                            <a href="javascript:download();" class="layui-btn layui-btn-danger layui-btn-radius" style="float: right">立即下载</a>
                            <button class="layui-btn layui-btn-radius" style="float: right">立即评论</button>
                            <div id="wenku_rate"></div>
                        </div>
                    </div>
                </div>
                    <div class="layui-card">
                        <div class="layui-card-body">
                            <h1 class="site-h1" style="font-size: 20px;">评论</h1>
                            <div class="site-h1" style="font-size: 20px;line-height: 30px">第一条评论</div>
                            <div class="site-h1" style="font-size: 20px;line-height: 30px">第一条评论</div>
                        </div>
                    </div>
            </div>
            <div class="layui-col-xs12  layui-col-md4">
                <%--<div class="grid-demo grid-demo-bg1">移动：0/12、桌面：4/12</div>--%>
                <div class="layui-card">
                    <div class="layui-card-body">
                        <h1 class="site-h1">相关推荐</h1>
                        <div class="site-h1" style="font-size: 20px;line-height: 30px">
                            <a href="">推荐1</a>
                        </div>
                        <div class="site-h1" style="font-size: 20px;line-height: 30px">
                            <a href="">推荐1</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>

</body>
</html>
<script src="${pageContext.request.contextPath}/jquery/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/layui/layui.js"></script>
<script type="text/javascript">
    var docLabelBeforeHtml = $('#wenku_label').html();
    var docLabel = $('#wenku_docLabel').text();
   docLabel.split('-').forEach(function(item){
       var docLabelHtml = '<span id = "wenku_docLabel" class="layui-badge-rim">'+ item +'</span>';
        if(item!=''){
            $('#wenku_label').html(docLabelBeforeHtml + docLabelHtml);
            docLabelBeforeHtml = $('#wenku_label').html();
        }
    })

    layui.use('rate', function(){
        var rate = layui.rate;

        //渲染
        var ins1 = rate.render({
            elem: '#wenku_rate',  //绑定元素
            readonly: true,
            half: true,
            value: 3.5,
            text: true
        });
    });
</script>
